package com.x.control;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.x.service.transactional.TransitTimeService;

@Controller
@RequestMapping("/transittime")
public class TransitTimeController {
	@Autowired(required = true)
	TransitTimeService transitTimeService;

	@RequestMapping(value = "/upload")
	public ModelAndView uploadShipments(
			@RequestParam(value = "file", required = false) MultipartFile file,
			HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("home");
		mv.addObject("nav", "configuration");
		if (transitTimeService.upload(file)) {
			mv.addObject("error",
					"create basic configuration fail: Duplicate Configs!");
		}
		return mv;
	}
}
